home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 32 / Amiga Format AFCD32 (Nov 1998, Issue 117).iso / -seriously_amiga- / programming / e / newgui / src / examples / guitask.e < prev    next >
Text File  |  1998-08-10  |  2KB  |  72 lines

  1. /* 
  2.  *  Runs the NewGUI-Engine (guimessage-handling) in a seperate Task
  3.  * -===============================================================-
  4.  * 
  5.  * 
  6.  */
  7.  
  8. OPT     LARGE 
  9. OPT     OSVERSION = 37
  10.  
  11. MODULE  'dos/dos'
  12. MODULE  'newgui/newgui'
  13. MODULE  'newgui/ng_guitask'
  14. MODULE  'newgui/ng_showerror'
  15.  
  16. ENUM    GUI_MAIN = 1,
  17.         GUI_WIN2
  18.  
  19. DEF     info:PTR TO guitaskinfo                 -> Guitaskinfo-Structure
  20.  
  21. PROC main()     HANDLE
  22.  opengui()                                      -> Open the gui (in a other task!)
  23.  
  24.   dootherthings()                               -> Do other things (like calculations...)
  25.  
  26. EXCEPT DO                                       -> Exception-Handling, but do it every time the program ends
  27.  ng_endtask(info)                               -> End and kill the gui-task
  28.   IF exception THEN ng_showerror(exception)     -> If any exception happened then show it
  29.  CleanUp(exception)                             -> Cleanup (with exception as return-code)
  30. ENDPROC
  31.  
  32. PROC opengui()                                  -> Should open the gui!
  33.   info:=ng_newtask(                             -> initialize a new task for the GUI!!!!
  34.        [NG_WINDOWTITLE,         'NewGUI-Task-Demo',
  35.         NG_AUTOOPEN,    TRUE,
  36.         NG_GUIID,       GUI_MAIN,
  37.         NG_GUI,
  38.                 [EQCOLS,
  39.                 [SPACEH],
  40.                         [SBUTTON,0,'End!'],
  41.                 [SPACEH]
  42.                 ],
  43.         NG_NEXTGUI,
  44. ->
  45.        [NG_WINDOWTITLE,         'NewGUI-Task-Window2',
  46.         NG_AUTOOPEN,    TRUE,
  47.         NG_GUIID,       GUI_WIN2,
  48.         NG_GUI, 
  49.                 [EQCOLS,
  50.                 [SPACEH],
  51.                         [SBUTTON,{test},'Test'],
  52.                 [SPACEH]
  53.                 ],
  54. ->
  55.         NIL,NIL],
  56.         NIL,NIL],NG_STACK_SIZE)                 -> NG_STACK_SIZE is Standart-Size of 4096 bytes!
  57. ENDPROC
  58.  
  59. PROC dootherthings()                            -> Do other important things...
  60.  DEF    a=0
  61.   Wait(info.sig OR SIGBREAKF_CTRL_C)            -> Wait until the GUI is ready (or Break!)
  62.    WHILE (ng_checkgui(info)=FALSE)              -> Wait until the GUI will be closed
  63.     Delay(1)                                    -> Give other Tasks our CPU-Time...
  64.      WriteF('\d ',a)                            -> Output the actual value of a
  65.     a++                                         -> calculate a(=a+1)
  66.    ENDWHILE
  67. ENDPROC
  68.  
  69. PROC test()                                     -> Test-Message!
  70.  WriteF('\ntest!\n')
  71. ENDPROC
  72.